package com.quzi.kettle.utils;

public class ByteUtils {

	public static String printHexString(byte[] b) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < b.length; i++) {
			// HEX String
			String hex = Integer.toHexString(b[i] & 0xFF);
			if (hex.length() == 1) {
				hex = '0' + hex;
			}
			sb.append(hex + ", ");
		}
		return sb.toString();
	}

	public static String printHexString(byte b) {
		StringBuilder sb = new StringBuilder();
		String hex = Integer.toHexString(b & 0xFF);
		if (hex.length() == 1) {
			hex = '0' + hex;
		}
		sb.append(hex + ", ");
		return sb.toString();
	}

	public static String getHexString(byte b) {
		// TODO Auto-generated method stub
		StringBuilder sb = new StringBuilder();
		String hex = Integer.toHexString(b & 0xFF);
		if (hex.length() == 1) {
			hex = '0' + hex;
		}
		sb.append(hex);
		return sb.toString();
	}
}
